<?php
// Check permission
require_once('project_files.class.php');

global $canEdit, $isProjectCompleted;
// Get quote_id from $_GET param
$project_id = intval(dPgetParam($_GET, "project_id", 0));
// Get login object
$uid = $AppUI->user_id;
// Prefix of project
$prefix = 'pfile_';
// path add Quotation
$pathDownload = './index.php?m=projects&a=do_file_crud&project_id='.$project_id.'&cmd=get';
$pathDeleteLine = './index.php?m=projects&a=do_file_crud&cmd=delete';
// Object
$obj = new CProject_files();
$final = $obj->getListByProjectId($uid, $project_id);
?>
<table width="100%" cellspacing="0" cellpadding="7" border="0" class="infopanel">
<tbody><tr>
	<td>
	<?php if($canEdit):?>
		<input type="button" value="<?=$AppUI->_('New File')?>" onclick="doCRUDFile(0, '&project_id=<?=$project_id?>')" class="button"/>
	<?php endif;?>
	</td>
</tr>
</tbody>
</table>
<table width="100%" cellspacing="0" cellpadding="2" border="0" class="list">
	<tbody>
		<tr>
			<th style="width: 20px;" nowrap="nowrap">&nbsp;</th>
			<th nowrap="nowrap"><?=$AppUI->_('Name')?></th>
			<th style="width: 60px;"><?=$AppUI->_('Version')?></th>
			<th nowrap="nowrap"><?=$AppUI->_('Description')?></th>
			<th style="width: 20px;">&nbsp;</th>
			<th style="width: 20px;">&nbsp;</th>
			<th style="width: 20px;">&nbsp;</th>
		</tr>
		<?php if((is_null($final)) or (!is_array($final)) or (sizeof($final) == 0)):?>
		<tr class="second">
			<td colspan="100">No item available</td>
		</tr>
		<?php else: ?>
		<?php $index = 0; foreach($final as $item):?>
			<?php $index += 1;?>
			<tr class="<?= ($index%2)==0 ? 'first': 'second' ?>">
				<td align="center"><?=$index?></td>
				<td><?=$item[$prefix.'name']?></td>
				<td align="center"><?=$item[$prefix.'version']?></td>
				<td><?=$item[$prefix.'description']?></td>
				<td align="center"><a href="<?=$pathDownload.'&suppressHeaders=1&pfile_id='.$item[$prefix.'id']?>"><img title="<?=$AppUI->_('Download')?>" src="images/download.gif" border="0"/></a></td>
				<td align="center">
					<?php if($canEdit):?>
						<a href="#" onclick="return doCRUDFile(<?=$item[$prefix.'id']?>,'&project_id=<?=$project_id?>')"><img title="<?=$AppUI->_('Edit')?>" src="images/edit.gif" border="0"/></a></td>
					<?php endif;?>
				<td align="center">
					<?php if($canEdit):?>
						<a href="<?=$pathDeleteLine.'&pfile_id='.$item[$prefix.'id']?>" ><img alt="<?=$AppUI->_('Delete')?>" src="images/delete.gif" border="0"/></a>
					<?php endif;?>
				</td>
			</tr>
			<?php endforeach;?>
		<?php endif;?>
	</tbody>
</table>
<div id="idCRUDFileDialog" class="popup" style="visibility: hidden; left: 436px; top: 94.5px; display: none;">
</div>